#ifndef TD_COORD2D_H_
#define TD_COORD2D_H_

#include <math.h>

namespace TD_Core {

	class Coord2D {
		
	public:
		/** Basic coordinate info:*/
		int x;
		int y;
		
		/************************************************************************/
		/* ctors and dtors				                                        */
		/************************************************************************/
		
		//Constructor default
		inline Coord2D() {
			x = y = 0;
		}
		//Copy constructor
		inline Coord2D(const Coord2D &rhs) {
			x = rhs.x;
			y = rhs.y;
			
		}
		//Assignment constructor
		Coord2D inline & operator=(const Coord2D &rhs) {
			x = rhs.x;
			y = rhs.y;
			return(*this);
		}

		//Initialization constructor 
		inline Coord2D(int g_x, int g_y) {
			x = g_x;
			y = g_y;
		}

		inline ~Coord2D() {
			//Do nothing
		}

		/************************************************************************/
		/* Arithmetic                                                           */
		/************************************************************************/		
		inline friend Coord2D operator + (const Coord2D &a, const Coord2D &b) {
			Coord2D ret(a);
			ret.x += b.x;
			ret.y += b.y;
			return(ret);
		}

		inline friend Coord2D operator - (const Coord2D &a, const Coord2D &b) {
			Coord2D ret(a);
			ret.x -= b.x;
			ret.y -= b.y;
			return(ret);
		}

		inline Coord2D &operator += (const Coord2D &a)  {
			x += a.x;
			y += a.y;
			return(*this);
		}

		inline Coord2D &operator -= (const Coord2D &a) {
			x -= a.x;
			y -= a.y;
			return(*this);
		}

		inline friend Coord2D operator + (const Coord2D &a, int b) {
			Coord2D ret(a);
			ret.x += b;
			ret.y += b;
			return(ret);
		}

		inline friend Coord2D operator * (const Coord2D &a, const Coord2D &b) {
			Coord2D ret(a);
			ret.x = a.x * b.x;
			ret.y = a.y * b.y;
			return(ret);
		}

		inline Coord2D &operator *= (const Coord2D &a)  {
			x *= a.x;
			y *= a.y;
			return(*this);
		}

		inline friend Coord2D operator * (const Coord2D &a, int b) {
			Coord2D ret(a);
			ret.x *= b;
			ret.y *= b;
			return(ret);
		}

		inline friend Coord2D operator / (const Coord2D &a, int b) {
			Coord2D ret(a);
			ret.x /= b;
			ret.y /= b;
			return(ret);
		}
		
		/************************************************************************/
		/* Geometric                                                            */
		/************************************************************************/
		
		inline float getModulus() const {
			return(
					sqrt(
						static_cast<float>(x*x + y*y)
						)
					);
		}

		//Class function
		inline float static DistanceBetween(const Coord2D &rhs, const Coord2D &lhs) {
			return (
					sqrt(
						pow(static_cast<float>(rhs.x - lhs.x), 2) + pow(static_cast<float>(rhs.y - lhs.y), 2)
						)
					);
		}




	};

}


#endif
